User configurable language independent code assist method, system, article of manufacture, and computer program product

ABSTRACT

A code assist function which suggests candidates responsive to a parsing of a partial program instruction statement by determining a current cursor position in the partial program instruction statement; parsing the partial program instruction statement before the current cursor position; generating a list of candidates to be inserted at the current cursor position responsive to the parsing of the partial program instruction statement; applying a user-selected preference to the list of candidates to generate a suggested list of candidates; displaying the list of suggested candidates; allowing a user to select one of the list of suggested candidates; and inserting at the current cursor position the user-selected suggested candidate. User-selectable preferences may be selected such as a longer or shorter list of candidates; a longer or shorter representation keyword candidates; a full syntax or partial syntax representation of a candidate; and a character case representation of a candidate.

CROSS-REFERENCE TO RELATED APPLICATIONS

Application Ser. No. ______, filed concurrently herewith on Dec. 9, 2003for USER CONFIGURABLE LANGUAGE INDEPENDENT CODE ASSIST ENGINE METHOD,SYSTEM, ARTICLE OF MANUFACTURE, AND COMPUTER PROGRAM PRODUCT (IBM DocketSTL9-2003-0037-US1), currently co-pending, and assigned to the sameassignee as the present invention; and

Application Ser. No. ______, filed concurrently herewith on Dec. 9, 2003for LANGUAGE INDEPENDENT CODE ASSIST USER PREFERENCES CONFIGURATIONMETHOD, SYSTEM, ARTICLE OF MANUFACTURE, AND COMPUTER PROGRAM PRODUCT(IBM Docket STL9-2003-0131-US1), currently co-pending, and assigned tothe same assignee as the present invention.

The foregoing co-pending applications are incorporated herein byreference.

A portion of the Disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates in general to computer programs, and moreparticularly to providing assistance to a programmer creating computerprogram code.

2. Description of the Related Art

A code assist or content assist is a function which aids a programmer inwriting a computer program statement by suggesting proposals orcandidates for insertion into the computer program statement. Theprogrammer may select one of the proposals or candidates in order tosupplement, modify, complete, or replace a computer program statementbeing edited.

Conventional code assist functions are exemplified by the EclipseProject code assist function as described in the Eclipse Project JavaDevelopment User Guide, (c) Copyright IBM Corp. 2000, 2001, pages 9-12,http://www.eclipse.org/eclipse/index.html. The Eclipse Project codeassist function provides a programmer with suggested assistance inwriting Java code. The programmer may activate the Eclipse Project codeassist function from a Java code editor on a line of Java computerprogram code which causes a scrollable list of available Java codecompletions to be displayed. The programmer may then select one of theproposed Java code completion candidates from the scrollable list to beinserted to complete the line of Java computer program code.

The programmer may also configure the behavior of the Eclipse Projectcode assist by selecting or specifying various preferences in a CodeAssist tab within a Java Editor preference page. Color preferences allowthe programmer to specify the colors used for the code assist window andthe colors used when showing method parameters. An alphabetical sortpreference, if enabled, causes proposals to be sorted in alphabeticalorder. A visibility preference limits displayed proposals in the list byJava visibility rules to only those proposals visible in a currentinvocation context. An argument name preference, if enabled, causes aselection of a Java method proposal to additionally insert the Javamethod's argument names as specified in the Java method's declaration. Aqualified versus import name preference allows the programmer to selectwhether the code assist function inserts fully qualified names for typeproposals or inserts non-qualified names for type proposals inconjunction with an addition of the corresponding import declaration. Apreference for automatic insertion of a single proposal when theproposal list only contains the single proposal may be specified. Theuser may also specify preferences as to the code assist function'sactivation behavior. An auto activation preference may specify that codeassist is invoked automatically in response to specified charactertriggers after a specified time delay.

Even with these capabilities and user-specified preferences,conventional code assist functions still fail to provide adequateassistance for a programming language which allows a variation in validsyntax for a particular command or verb, a variation in keywordrepresentations for a particular keyword, variations in valid argumenttypes for a particular command or verb, or variations in style such ascharacter case. In view of these possible variations, a user may preferonly one of the variations, or the user may prefer to be reminded of allof the possible variations.

In particular, these conventional code assist functions fail to provideadequate assistance for variable-syntax programming languages such asCOBOL or PL/I having these complexities. Complex languages such as COBOLmay have numerous variations in syntax for a single statement. Forexample, a COBOL GOTO statement has the syntax: “GO” [“TO”]procedure-name, which gives rise to two format variations: “GO TOprocedure-name” and “GO procedure-name”. The COBOL MOVE statement hasthe following syntax:

-   -   “MOVE” [CORRESPONDING|CORR] {identifier-1|literal-1} “TO”        identifier-2 and has six format variations:    -   “MOVE CORRESPONDING identifier-1 TO identifier-2”    -   “MOVE CORRESPONDING literal-1 TO identifier-2”    -   “MOVE CORR identifier-1 TO identifier-2”    -   “MOVE CORR literal-1 TO identifier-2”    -   “MOVE identifier-1 TO identifier-2”    -   “MOVE literal-1 TO identifier-2”        In a complex language such as COBOL, keywords may have        alternative spellings. For example, COBOL keywords may have the        following alternative spellings: “CORRESPONDING” or “CORR”,        “IDENTIFICATION” or “ID”, “JUSTIFIED” or JUST”, “PICTURE” or        “PIC”, “SYNCHRONIZED” or “SYNC”, and “THROUGH” or “THRU”.        Alternatively, keywords or reserve words may be optional, such        as the optional keyword “TO” in the above GOTO statement or the        optional keyword CORRESPONDING in the above MOVE statement.        Further complexities may result from keywords dictating a        subsequent format of a statement, or from a format being        recursive.

A programmer desiring an effective code assist function for such acomplex programming language needs a code assist function which supportssuch complexity variations, supports user-specified preferences for suchcomplexity variations, and which effectively provides suggestedproposals for completing programming statements having such complexityvariations. However, conventional code assist functions fail to providethis. Thus, there is a clearly felt need for an improved code assistfunction for such complex language variations.

SUMMARY OF THE INVENTION

Preferred embodiments of the present invention comprise a method,system, article of manufacture, and computer program product forproviding code assist.

In accordance with a preferred embodiment of the present invention, acode assist function which suggests candidates responsive to a parsingof a partial program instruction statement by determining a currentcursor position in the partial program instruction statement; parsingthe partial program instruction statement before the current cursorposition; generating a list of candidates to be inserted at the currentcursor position responsive to the parsing of the partial programinstruction statement; applying a user-selected preference to the listof candidates to generate a suggested list of candidates; displaying thelist of suggested candidates; allowing a user to select one of the listof suggested candidates; and inserting at the current cursor positionthe user-selected suggested candidate. User-selectable preferences maybe selected such as a longer or shorter list of candidates; a longer orshorter representation keyword candidates; a full syntax or partialsyntax representation of a candidate; and a character caserepresentation of a candidate.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function.

A preferred embodiment of the present invention has the advantage ofproviding an improved user interface for a code assist function.

A preferred embodiment of the present invention has the advantage ofproviding a user-configurable set of user preferences for configuring anoperation of an improved code assist function.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function supporting multiple computerprogramming languages.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function supporting multiple syntaxand format variations for a single computer programming statement.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function supporting multiple keywordvariations for a particular keyword of a computer programming statement.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function supporting optional keywordsfor a particular computer programming language command or verb.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function supporting computerprogramming language commands or verbs containing recursive syntax.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function providing a list of commandsor verbs, key words, identifier names, and literal names as proposals ata current cursor position in a computer program statement.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function providing a user-selectablechoice of either a shorter list or a longer list of proposals.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function providing a user-selectablepreference as to a case of a proposal: upper case, lower case, or mixedcase.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function providing a user-selectablechoice from available formats for a particular command or verb.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function providing a user-selectablechoice of either full or abbreviated representations of a keyword.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function displaying a suggestedcandidate responsive to a determination of declared variables andconstants.

A preferred embodiment of the present invention has the advantage ofproviding an improved code assist function displaying a suggestedcandidate responsive to a determination of a code segment containing apartial program instruction statement.

BRIEF DESCRIPTION OF THE DRAWINGS

For a more complete understanding of the present invention and theadvantages thereof, reference is now made to the Description of thePreferred Embodiment in conjunction with the attached Drawings, inwhich:

FIG. 1 through FIG. 7 are graphical user interfaces used in a preferredembodiment of the present invention;

FIG. 8 is a block diagram the preferred embodiment of the presentinvention;

FIG. 9 is a class diagram of the preferred embodiment of the presentinvention;

FIG. 10 through FIG. 12 are flowcharts of method steps preferred incarrying out the preferred embodiment of the present invention; and

FIG. 13 is a block diagram of a computer system used in performing amethod of a preferred embodiment of the present invention, forming partof an apparatus of a preferred embodiment of the present invention,storing a data structure of a preferred embodiment of the presentinvention, and which may use an article of manufacture comprising acomputer-readable storage medium having a computer program embodied insaid medium which may cause the computer system to practice a preferredembodiment of the present invention.

DESCRIPTION OF THE PREFERRED EMBODIMENT

An embodiment of the invention is now described with reference to thefigures where like reference numbers indicate identical or functionallysimilar elements. Also in the figures, the left most digit of eachreference number corresponds to the figure in which the reference numberis first used. While specific configurations and arrangements arediscussed, it should be understood that this is done for illustrativepurposes only. A person skilled in the relevant art will recognize thatother configurations and arrangements can be used without departing fromthe spirit and scope of the invention. It will be apparent to a personskilled in the relevant art that this invention can also be employed ina variety of other devices and applications.

FIG. 1 illustrates an editor screen or window 110 displaying a COBOLsource code file in which a blank line 120 has been inserted by theuser. The user may activate the code assist function by pressing a keyor key combination, such as CONTROL-SPACE, which causes the code assistfunction to display a window 130 containing a list 140 of proposals orproposed candidates to insert at the current cursor position 120. Theuser may select one of the proposals from the list by clicking a mousecursor on the proposal to be selected, and responsive to the user'sselection of the selected proposal, the selected proposal is inserted atthe current cursor position. The user may also scroll the list up anddown to find the desired proposal. Alternatively, the user may usekeystrokes, such as up arrow, down arrow, tab, return, or enter keys, toscroll, navigate, and select within the list 140.

If the user desires to insert a MOVE statement at the current cursorposition 120, then the user may scroll down the list 140 until a MOVEkeyword proposal is displayed. The user may then select the MOVE keywordproposal to be inserted which results in the window 210 of FIG. 2 inwhich the MOVE keyword 220 is inserted in the partial program statement230, and in which the current cursor position 240 is moved after theinserted keyword. Responsive to the partial program statement 230 nowcomprising the MOVE keyword 220, the code assist function suggestsfurther proposal candidates 250 for insertion at the now current cursorposition 240. Based upon the syntax of a MOVE program statement, thecode assist function suggests proposal candidates comprising thekeywords CORRESPONDING and CORR which may follow the MOVE keyword, andcomprising identifiers or variables declared within the program whichmay follow the MOVE keyword, but excluding those identifiers whichcannot be specified in a MOVE statement. For example, in some COBOLdialects, data items described with the following types of usage cannotbe specified in a MOVE statement: INDEX, POINTER, FUNCTION-POINTER,PROCEDURE-POINTER, and OBJECT REFERENCE

If the user selects the CORR keyword proposal 260 for the next insertionat the current cursor position 240, the window 310 of FIG. 3 results inwhich the CORR keyword 330 has been inserted at the end of the partialprogram statement 320 and in which the current cursor position 340 ismoved after the inserted keyword 330. Responsive to the partial programstatement 320 now comprising the MOVE and CORR keywords, the code assistfunction suggests further proposal candidates 350 for insertion at thenow current cursor position 340. Based upon the syntax of the MOVEprogram statement, the code assist function suggests proposal candidatescomprising identifiers or variables declared within the program whichmay follow the MOVE statement CORR keyword.

The user may now select one of the literal or variable proposals from350 such as the In-Name proposal 360 for the next insertion at thecurrent cursor position 340. The window 410 of FIG. 4 results in whichthe In-Name literal and TO keyword 430 have been inserted at the end ofthe partial program statement 420 and in which the current cursorposition 440 is moved after the inserted literal and keyword 430.Responsive to the partial program statement 420 now comprising the MOVEand CORR keywords followed by the literal In-Name and the TO keyword,the code assist function suggests further proposal candidates 450 forinsertion at the now current cursor position 440. Based upon the syntaxof the MOVE program statement, the code assist function suggestsproposal candidates comprising identifiers or variables declared withinthe program which may follow the MOVE statement TO keyword.

The literal or variable proposal Out-Name 460 from the window 450 may beselected by the user for the next insertion at the current cursorposition 440. The window 510 of FIG. 5 results in which the Out-Nameliteral has been inserted at the end of the program statement 520. Thisinsertion results in a complete program statement 520, and responsive tothis complete program statement 520 comprising a complete MOVE programstatement, the code assist function does not suggest any furtherproposal candidates 350 for this complete program statement 520.

Referring now to FIGS. 6 and 7, graphical user interfaces which may beused to configure the operation of the code assist function of thepreferred embodiment are illustrated. Referring first to FIG. 6, window605 provides a graphical user interface which enables the user tospecify user-selectable preferences as to the operation of the codeassist function of the preferred embodiment. The user may selectchecklist item 610 to cause the code assist function to display a longerlist of candidates responsive to the parsing of a partial programinstruction statement, or alternatively, the user may select checklistitem 615 to cause the code assist function to display a shorter list ofcandidates responsive to the parsing of the partial program instructionstatement. For example, the longer list of candidates may comprise allcandidates suggested by the code assist function; whereas, the shorterlist may comprise categories of candidates such as keywords,identifiers, or literals from which the user may select to display thecandidates in the selected category.

As a default behavior of the code assist function, the user may specifya preference as to longer representations displaying full keywords orshorter representations displaying abbreviated keywords in proposalcandidates suggested by the code assist function. The user may selectchecklist item 620 to cause a display of a longer representation of aprogram instruction keyword candidate responsive to the parsing of apartial program instruction statement, or the user may select checklistitem 625 to cause a display of a shorter representation of a programinstruction keyword candidate responsive to the parsing of the partialprogram instruction statement. For example, if the user has selectedchecklist item 620 indicating a preference for longer full keywordrepresentations, then the code assist function will display in suggestedproposal candidates full keywords such as “CORRESPONDING”,“IDENTIFICATION”, “JUSTIFIED”, “PICTURE”, “SYNCHRONIZED”, and “THROUGH”.If the user has selected checklist item 625 indicating a preference forshorter abbreviated keyword representations, then the code assistfunction will display in suggested proposal candidates shorterabbreviated keywords such as “CORR”, “ID”, “JUST”, “PIC”, “SYNC”, and“THRU”.

The user may also specify a preference as to the case of the suggestproposal candidates. The user may select checklist item 630 to causeproposal candidates to be displayed in a lower-case representation(i.e., “move”), checklist item 635 to cause proposal candidates to bedisplayed in an upper-case representation (i.e., “MOVE”), or checklistitem 640 to cause proposal candidates to be displayed in a mixed-case orleading upper-case representation (i.e., “Move”).

As a further default behavior of the code assist function, the user mayspecify a preference as to displaying a full syntax representation or apartial syntax representation. The user may select checklist item 645 tocause a display of a full syntax representation of a program instructionverb candidate responsive to the parsing of a partial programinstruction statement, or the user may select checklist item 650 tocause a display of a partial syntax representation of a programinstruction verb candidate responsive to the parsing of a partialprogram instruction statement. For example, if the user has selectedchecklist item 645 indicating a preference for a full syntaxrepresentation, then the code assist function will display a MOVEinstruction candidate in the full syntax: “MOVE CORRESPONDINGIDENTIFIER-1 TO IDENTIFIER-2”. If the user has selected checklist item650 indicating a preference for a partial syntax representation, thenthe code assist function may display a MOVE instruction candidate in apartial syntax: “MOVE IDENTIFIER-1 TO IDENTIFIER-2”.

Although the user may specify user-selected preferences applicable toall candidates proposed by the code assist function, the user may alsooverride these general preferences with verb-specific preferences byselecting checklist item 655 which causes a display of a list of verbsfrom which the user may select one verb to specify verb-specificpreferences. If the user selects one of the verbs, such as “MOVE”, tospecify verb-specific preferences, then a window 700 of FIG. 7 isdisplayed. Even though the user may have specified shorter abbreviatedkeywords as the default behavior of the code assist function, the usermay specify a verb-specific preference of full keywords for the selectedverb which overrides the general default behavior. For example, if theuser has selected checklist item 705 indicating a preference for longerfull keyword representations for the MOVE instruction, then the codeassist function will display in suggested proposal candidates fullkeywords such as “MOVE CORRESPONDING” as opposed to the generalpreference of shorter abbreviated keywords such as “ADD CORR” or“SUBTRACT CORR”. Similarly, checklist item 710 allows the user tooverride a general preference for longer full keywords with averb-specific preference of shorter abbreviated keywords.

In a similar fashion, the user may use upper-case checklist item 715,lower-case checklist item 720, and mixed-case checklist item 725 tospecify a verb-specific preference for the selected verb which overridesthe general default behavior specified in window 605.

The Statement Syntax section 730 of the verb-specific preferences window700 allows the user to select one preferred syntax from a plurality ofvalid syntax representations. For example, for the MOVE instruction,Statement Syntax section 730 allows the user to select from a fullkeyword full syntax representation 735 comprising “MOVE CORRESPONDINGIDENTIFIER1 TO IDENTIFIER2”; an abbreviated full syntax representation740 comprising “MOVE CORR IDENTIFIER1 TO IDENTIFIER2”, a partial syntax750 comprising “MOVE IDENTIFIER1 TO IDENTIFIER2”, or an alternativepartial syntax 755 “MOVE LITERAL1 TO IDENTIFIER2”. The preferred syntaxselected by the user will be used by the code assist function when itsuggests proposal candidates for that particular verb.

Alternatively, to select the syntax preference for the instruction, theuser may click on the checklist item Selectable Statement Syntax 760which allows the user to click on portions of the syntax diagram tospecify the syntax preference. For example, the user may click on “MOVE”765, “CORRESPONDING” 770, “IDENTIFIER1”780, “TO” 790, and “IDENTIFIER2”795 to identify and select the following full keyword full syntaxrepresentation of the MOVE instruction: “MOVE CORRESPONDING IDENTIFIER1TO IDENTIFIER2”. In lieu of selecting “CORRESPONDING” 770, the user mayselect “CORR” 775 which results in the user identifying and selectingthe following abbreviated keyword full syntax representation: ““MOVECORR IDENTIFIER1 TO IDENTIFIER2”. If the user clicks on “MOVE” 765,“IDENTIFIER1”780, “TO” 790, and “IDENTIFIER2” 795, then the partialsyntax “MOVE IDENTIFIER1 TO IDENTIFIER2” is identified and selected asthe syntax representation of the MOVE instruction. Alternatively, theuser may click on “MOVE” 765, “LITERAL1” 785, “TO” 790, and“IDENTIFIER2” 795 to identify and select the following alternativepartial syntax representation of the MOVE instruction: “MOVECORRESPONDING LITERAL1 TO IDENTIFIER2”.

In lieu of these graphical user interface techniques, the user mayselect the checklist item Edit Syntax Statement File 797 to directlyedit the syntax statement rules contained in the syntax statement fileused by the code assist function parser.

Referring now to FIG. 8, a block diagram of the preferred embodiment ofthe present invention is illustrated. A programmer may open a programfile 810 with editor 820 to edit program source code contained in theprogram file 810. If the programmer requests code assist or contentassist, it is provided by Code Assist Engine 830 which uses a SyntaxLibrary appropriate for the programming language in which the program ofprogram file 810 is written. If program file 810 is written in COBOL,then the Code Assist Engine 830 uses a COBOL Syntax Library 840 toprovide code assist. Alternatively, if the program file 810 is writtenin another programming language, such as PL/I, C++, or Java for example,then the Code Assist Engine 830 uses either a PL/I Syntax Library 850,C++ Syntax Library 860, or Java Syntax Library 870 to provide codeassist. These programming languages are merely exemplary examples as aSyntax Library may be written to support any programming language. TheCode Assist Engine 830 may determine which Syntax Library is appropriateto use with program file 810 by analyzing either attributes or contentof program file 810. For example, if a file attribute such as a filename extension is “cbl” indicating that program file 810 is a COBOLprogram file, then the Code Assist Engine 830 uses COBOL Syntax Library840. Alternatively, Code Assist Engine 830 may analyze the content ofprogram file 810 to determine that it contains COBOL program code andthat COBOL Syntax Library 840 should be used. In still otherembodiments, the Syntax Library used by the Code Assist Engine 830 maybe based upon a user-specified preference, a user-specified selection,or a history file.

Referring now to FIG. 9, a class diagram of the preferred embodiment ofthe present invention is illustrated. The classes comprise aCompletionProcessor class 902, Editor class 910, VariablesParser class908, UserStatement class 906, SyntaxLibrary class 904, CursorEnginesclass 920, Normal CursorEngine class 924, and Recursive CursorEngineclass 926.

The CompletionProcessor class 902 manages the overall operation of thecode assist function, and comprises methods getCurrentText( ) 914,getImages( ) 942, CompleteCompletionProposals( ) 952, andcompletionProposals( ) 912. The method getCurrentText( ) 914 calls theeditor 910 for the elementText( ) 916 to get the partial statement to beparsed to provide code assist. The methods CompleteCompletionProposals() 952, completionProposals( ) 912 and getImages( ) 942 match a type fromeach proposal of the combined proposal vector to an image and returnthese images to the CompletionProcessor 902.

The Editor class 910 provides editing functions for the program filebeing edited, and comprises elementText( ) 916 which provides thepartial statement to getCurrentText( ) 914.

The VariablesParser class 908 parses the program to identify variablesand functional constants, and comprises methods getvariables( ) 938,getdivision( ) 954, and getFigurativeConstants( ) 940. The methodgetvariables( ) 938 parses the program to identify variables. The methodgetdivision( ) 954 gets Syntax Statements from SyntaxLibrary 904 toparse a current division of the program file. The methodgetFigurativeConstants( ) 940 parses the program to identify and getfunctional constants.

The UserStatement class 906 parses the partial statement based uponSyntax Statements obtained from the Syntax Library 904, and comprisesmethods parseUserStatment( ) 918, and getstatement( ) 948. The methodparseUserStatment( ) 918 parses the partial statement, and the methodgetStatement( ) 948 obtains the appropriate Syntax Statements from theSyntax Library 904.

The SyntaxLibrary class 904 stores an array of Syntax Statementsdescribing the syntax of a particular programming language, andcomprises methods getVerbs( ) 956, getKeyWords( ) 958, isCommand( ) 960,is KeyWord( ) 962, getSyntaxStatmnts( ) 964, getVariables( ) 966, andfindSyntaxStatement( ) 968. The method getVerbs( ) 956 returns thecommands supported by the programming language for which theSyntaxLibrary stores the programming language syntax. A command isnormally the first keyword of a programming language statement. Themethod getKeyWords( ) 958 returns the keywords, excluding commandkeywords, supported by the programming language for which theSyntaxLibrary stores the programming language syntax. The methodisCommand( ) 960 tests whether a token is a command. The method isKeyWord( ) 962 tests whether a token is a keyword. The methodgetSyntaxStatmnts( ) 964 gets the syntax statements as defined in aSyntaxLibrary for a particular programming language. The methodgetvariables( ) 966 gets the variables defined in the source program asdetected by VariablesParser. The method findSyntaxStatement( ) 968 findssyntax statements in the SyntaxLibrary which match a given command.

Within the SyntaxLibrary class 904, language syntax diagrams areconverted into syntax statement strings and stored in an array ofstrings forming a Syntax Statement Library. The first keyword in eachsyntax statement is the command or verb, and is distinguished from otherkeywords. When an incomplete programming language statement is presentedto the Code Assist Engine 830, it matches the statement command or verbto the command keywords in the syntax statements producing a resultcomprising those matching syntax statements to be considered forsubsequent processing which generates proposals.

Within syntax statements, special characters are used to delimit thesyntax statements as follows: Character Significance &n, &rn “&n” and“&rn” are recursion labels. “&n” labels a start of a recursion within asyntax statement wherein n is a number from 0 to 9. An “&n” is pairedwith an “&rn” which indicates the end of a recursion. The second “&rn”causes a branch back or recursion to the first “&n”. [ | ] Bracketsindicate Or phrases in which a syntax statement requires either thefirst item located before the vertical bar within the brackets or thesecond item located after the vertical bar within the brackets. { }“{“and“}” indicate phrase boundaries wherein once started a phrase mustbe completed, as opposed to Or phrases which do not have to becompleted. $ “$” indicates a conditional which may be applied tokeywords (i.e., $TO), Or phrases (i.e., $[ | ]), and phrases (i.e., ${}). &a “&a” are symbol labels wherein “a” may be either “i”, “s”, “b”,“l”, “p”, etc. representing identifiers, statements, both, literal,procedure names, etc.

As stated above, a Syntax Statement Library is an array of syntaxstatement strings using the above notation. Given a syntax diagram foreach format of each statement, the syntax statements may be written bymatching the syntax diagram to the syntax statement notation, includingrecursion phrases. Different Syntax Statement Libraries may representdifferent programming languages without modifying the Code AssistEngine. Furthermore, different Syntax Statement Libraries may be used torepresent the same programming language, such as having a differentSyntax Statement Library for each COBOL division, like IDENTIFICATION,PROCEDURE, etc.

For example, the syntax of a COBOL ALTER statement may be represented byand stored in the Syntax Statement Library by the syntax statement:

-   -   “ALTER &1 &p TO ${PROCEED TO} &p &r1”        Within this ALTER syntax statement, “ALTER”, “TO” and “PROCEED”        are keywords. “ALTER” as the first keyword in the syntax        statement is considered to be the command or verb. Commands are        determined by getting the first unique keyword in each syntax        statement. “&1” and “&r1” are a recursive pair indicating the        recursion “&1 &p TO ${PROCEED TO} &p &r1”. “{” and “}” mark a        phrase “PROCEED TO”that once started must be completed. The “$”        marks the phrase “{PROCEED TO} ”as conditional or optional. “&p”        represents a procedure symbol. Note that symbols from the syntax        statement match identifiers or variables from the user statement        and not keywords; whereas, keywords in the syntax statement        match keywords in the user statement.

The processing of the syntax statements of the Syntax Statement Libraryoccurs in two primary stages: moving the cursor, and creating proposals.The first stage of moving the cursor starts with a character stringreturned from getCurrentText( ). This character string is the partialuser statement. The partial user statement is parsed into tokens whichare compared one by one against tokens in one or more syntax statements,such as the above mentioned COBOL syntax statement representing theCOBOL ALTER command. Tokens are divided into keywords and variables. Aslong as matching between the user statement tokens and the syntaxstatement tokens occurs, the cursor is moved to the start of the nexttoken. The cursor moving stage performs the token matching according tothe keywords, phrases, and symbols specified in a syntax statement. Whenall of the tokens from the partial user statement are processed, thecursor moving stage is complete. If necessary, a same portion of asyntax statement (e.g., between “&1” and “&r1 ”) is parsed again tocontinue matching if a recursion is matched.

The second stage of creating proposals starts with a cursor index leftby the first stage of moving the cursor, wherein this cursor indexindicates a position of the last matching tokens. The second stage thenmoves forward from this cursor index position to generate one or moreproposals. For example, if the first cursor moving stage had matched thepartial user statement against the following ALTER syntax statementthrough the conditional “$”:

-   -   “ALTER &1 &p TO ${PROCEED TO} &p &r1 ”        then the second stage of creating proposals starts with a cursor        index pointing to the conditional “$” in the ALTER syntax        statement as the first stage has already matched the tokens        “ALTER & 1 &p TO” between the syntax statement and the partial        user statement. The second stage of creating proposals will then        generate “PROCEED TO” as a proposal. Since “PROCEED TO” is an        optional conditional, the second stage will also generate a        proposal without “PROCEED TO” which would be the next token        comprising a procedure name.

If the cursor from the first stage is indexing the end of a recursionphrase, such as the “&r1” in the above ALTER syntax statement, then thesecond stage would generate another proposal comprising a second “&p TO&p”, i.e., “procedure-name1 TO procedure-name2”. If the cursor from thefirst stage is indexing the start of an Or phrase, all of thealternative values within the Or phrase would be generated as proposals.

The CursorEngines class 920 creates and controls a CursorEngine for eachSyntax Statement, and comprises methods createEngines( ) 922,generateProposals( ) 950, and executeCursorEngines( ) 928. The methodcreateEngines( ) 922 inspects a Syntax Statement and creates an instanceof a normal CursorEngine, and if it detects a recursion loop in theSyntax Statement, then it also creates one instance of a recursiveCursorEngine for each recursion loop detected in the statement. Themethod generateProposals( ) 950 requests that each Normal CursorEngine() 924 and each recursive CursorEngine( ) 926 created by itsCursorEngines 920 to create proposals based upon their prior parsing ofthe partial statement. The method executeCursorEngines( ) 928 requeststhat each Normal CursorEngine( ) 924 and each recursive CursorEngine( )926 created by its CursorEngines 920 begin cursor movement and parsingof the partial statement.

The Normal CursorEngine class 924 parses a single Syntax Statement, andcomprises methods moveSyntaxCursor( ) 930, parseSyntaxStatement( ) 944,and createProposal( ) 934. The methods moveSyntaxCursor( ) 930 andparseSyntaxStatement( ) 944 request that a normal CursorEngine parsesits Syntax Statement as driven by the parsing of the partial statement.The method createProposal( ) 934 requests that a Normal CursorEngine( )924 create proposals based upon its prior parsing of the partialstatement.

The Recursive CursorEngine class 926 parses a single recursion within asingle Syntax Statement, and comprises methods moveSyntaxCursor( ) 932,parseSyntaxStatement( ) 946, and createProposal( ) 936. The methodsmoveSyntaxCursor( ) 932 and parseSyntaxStatement( ) 946 request that aRecursive CursorEngine parses its Syntax Statement as driven by theparsing of the partial statement. The method createProposal( ) 936requests that a Recursive CursorEngine( ) 924 create proposals basedupon its prior parsing of the partial statement.

Referring now to FIG. 10 through FIG. 12, the flowcharts 1000, 1100, and1200 illustrate the operations preferred in carrying out the preferredembodiment of the present invention. In the flowcharts, the graphicalconventions of a diamond for a test or decision and a rectangle for aprocess or function are used. These conventions are well understood bythose skilled in the art, and the flowcharts are sufficient to enableone of ordinary skill to write code in any suitable computer programminglanguage.

Referring first to FIG. 10, after the start 1010 of the process 1000,process block 1020 creates an instance of a CompletionProcessor 902registered for an appropriate programming language (i.e., cbl fileextensions for COBOL), an instance of UserStatement 906, an instance ofa VariablesParser 908, and an instance of a SyntaxLibrary 904 for eachDivision within the program file being edited by editor 910. Processblock 1030 monitors for a user requesting the code assist functionthrough the use of a key combination such as Control-Space afterentering a partial COBOL statement. Alternatively, the user may activatethe code assist function through other input devices and user interfaceswell known to those skilled in the art. Responsive to the user'sactivation of the code assist function, process block 1040 of theCompletionProcessor 902 calls CompletionProcessor#completionProposals( )912. Process block 1050 of the CompletionProcessor 902 callsgetCurrentText( ) 914 which calls elementText( ) 916 of the editor 910to get the partial statement upon which the code assist function wasactivated. The instance of UserStatement#parseStatment( ) 918 is calledby process block 1060 of CompletionProcessor 902 to begin the proposalgeneration. UserStatement#parseStatment( ) 918 parses the partialstatement provided by the editor 910 and uses a command (or verb)contained in the partial statement to locate Syntax Statement(s) viagetStatement 948, locating one Syntax Statement for each formatvariation in the appropriate SyntaxLibrary 904 for the current COBOLDivision. Process block 1070 creates one instance of CursorEngines 920for each Syntax Statement format variation. Control then passes toprocess block 1120 on FIG. 11, illustrated by flowchart connectors A,1080 on FIGS. 10 and 1110 on FIG. 11.

Referring now to FIG. 11, after control passes to process block 1120,process block 1120 of createEngines( ) 922 inspects its Syntax Statementand creates one normal CursorEngine 924 and one recursive CursorEngine926 for each recursion loop detected in the statement, if any. Processblock 1130 of CursorEngines 920 invokes executeCursorEngines 928 tobegin a cursor movement phase. During this cursor movement phase,process block 1140 of the normal CursorEngine 924 asks moveSyntaxCursor() 930 to parse its syntax statement via parseSyntaxStatement( ) 944 asdriven by a parsing of the user-entered partial statement. If arecursive Syntax Statement is detected, then process block 1150 of thenormal CursorEngine 924 calls an appropriate recursive CursorEngine 926which asks moveSyntaxCursor( ) 932 to parse its recursive SyntaxStatement via parseSyntaxStatement( ) 946 as driven by a parsing of theuser-entered partial statement. Cursor movement within the user-enteredpartial statement continues until a recursive CursorEngine( ) 926mismatches tokens from the user-entered partial statement, or until therecursive CursorEngine( ) 926 reaches a match between its SyntaxStatement and the partial user statement, at which point the recursiveCursorEngine 926 returns to the normal CursorEngine 924. The normalCursorEngine 924 continues to move its cursor until a mis-match occurs,until more recursion syntax is reached, or until the end of theuser-entered partial statement is reached. Control then passes toprocess block 1220 on FIG. 12, illustrated by flowchart connectors B,1160 on FIGS. 11 and 1210 on FIG. 12.

Referring next to FIG. 12, after control passes to process block 1220,process block 1220 begins the proposal generation phase in whichgenerateProposals( ) 950 of CursorEngines( ) 920 asks NormalCursorEngine( ) 924 and recursive CursorEngine( ) 926 to createproposals based upon their prior parsing via createProposal( ) (934 and936). To create these proposals, each CursorEngine (924 or 926),starting from the current cursor location, moves the cursor forwardgenerating zero or more proposals. Keywords from the Syntax Statementmay added to a proposals vector as proposals. If the current cursorposition within the user-entered partial statement is setting on anidentifier, then corresponding variables and functional constants areobtained from VariablesParser#getVariables( ) 938 andVariablesParser#getFigurativeConstants( ) 940. These correspondingvariables and functional constants may also be added to the proposalsvector. Thereafter, process block 1230 concatenates the proposals(strings and types) vectors from each CursorEngine (924 or 926) in eachinstance of CursorEngines (924 or 926) across an array of formatvariation(s) to create a single combined proposal vector which isreturned to CompletionProcessor 902. Process block 1240 ofCompletionProcessor 902 causes completionProposals( ) 912 to match atype from each proposal of the combined proposal vector to an image viagetImages( ) 942 and to return these images to the CompletionProcessor902 which displays a pop-up window (130, 250, 350, or 450) containingthe proposal images from which the user can select a proposed Keyword,identifier or constant to continue the entry of the partial statement.After all processing is completed, the process ends at process block1250.

With reference now to the figures, and in particular with reference toFIG. 13, there is depicted a pictorial representation of a computersystem 1300 which may be utilized to implement a method, system, articleof manufacture, data structure, and computer program product ofpreferred embodiments of the present invention. The block diagram ofFIG. 13 illustrates a computer system 1300 used in performing the methodof the present invention, forming part of the apparatus of the presentinvention, and which may use the article of manufacture comprising acomputer-readable storage medium having a computer program embodied insaid medium which may cause the computer system to practice the presentinvention. The computer system 1300 includes a processor 1302, whichincludes a central processing unit (CPU) 1304, and a memory 1306.Additional memory, in the form of a hard disk file storage 1308 and acomputer-readable storage device 1310, is connected to the processor1302. Computer-readable storage device 1310 receives a computer-readablestorage medium 1312 having a computer program embodied in said mediumwhich may cause the computer system to implement the present inventionin the computer system 1300. The computer system 1300 includes userinterface hardware, including a mouse 1314 and a keyboard 1316 forallowing user input to the processor 1302 and a display 1318 forpresenting visual data to the user. The computer system may also includea printer 1320.

Using the foregoing specification, the invention may be implementedusing standard programming and/or engineering techniques using computerprogramming software, firmware, hardware or any combination orsub-combination thereof. Any such resulting program(s), having computerreadable program code means, may be embodied within one or more computerusable media such as fixed (hard) drives, disk, diskettes, opticaldisks, magnetic tape, semiconductor memories such as Read-Only Memory(ROM), Programmable Read-Only Memory (PROM), etc., or any memory ortransmitting device, thereby making a computer program product, i.e., anarticle of manufacture, according to the invention. The article ofmanufacture containing the computer programming code may be made and/orused by executing the code directly or indirectly from one medium, bycopying the code from one medium to another medium, or by transmittingthe code over a network. An apparatus for making, using, or selling theinvention may be one or more processing systems including, but notlimited to, central processing unit (CPU), memory, storage devices,communication links, communication devices, servers, input/output (I/O)devices, or any sub-components or individual parts of one or moreprocessing systems, including software, firmware, hardware or anycombination or sub-combination thereof, which embody the invention asset forth in the claims. User input may be received from the keyboard,mouse, pen, voice, touch screen, or any other means by which a human caninput data to a computer, including through other programs such asapplication programs, databases, data sets, or files.

One skilled in the art of computer science will easily be able tocombine the software created as described with appropriate generalpurpose or special purpose computer hardware to create a computer systemand/or computer sub-components embodying the invention and to create acomputer system and/or computer sub-components for carrying out themethod of the invention. Although the present invention has beenparticularly shown and described with reference to a preferredembodiment, it should be apparent that modifications and adaptations tothat embodiment may occur to one skilled in the art without departingfrom the spirit or scope of the present invention as set forth in thefollowing claims.

1. An article of manufacture for use in a computer system for providinga code assist function which suggests candidates responsive to a parsingof a partial program instruction statement, said article of manufacturecomprising a computer-useable storage medium having a computer programembodied in said medium which causes the computer system to executemethod steps comprising: determining a current cursor position in thepartial program instruction statement; parsing the partial programinstruction statement before the current cursor position; generating alist of candidates to be inserted at the current cursor positionresponsive to the parsing of the partial program instruction statement;applying a user-selected preference to the list of candidates togenerate a suggested list of candidates; displaying the list ofsuggested candidates; allowing a user to select one of the list ofsuggested candidates; and inserting at the current cursor position theuser-selected suggested candidate.
 2. The article of manufacture ofclaim 1 wherein the user-selected preference comprises displaying alonger list of suggested candidates in lieu of a shorter list ofsuggested candidates.
 3. The article of manufacture of claim 1 whereinthe user-selected preference comprises displaying a shorter list ofsuggested candidates in lieu of a longer list of suggested candidates.4. The article of manufacture of claim 1 wherein the user-selectedpreference comprises displaying a longer representation of a programinstruction verb suggested candidate in lieu of a shorter representationof a program instruction verb suggested candidate.
 5. The article ofmanufacture of claim 1 wherein the user-selected preference comprisesdisplaying a full syntax representation of a suggested candidate in lieuof a partial syntax representation of a suggested candidate.
 6. Thearticle of manufacture of claim 1 wherein the user-selected preferencecomprises one from the set comprising displaying a lower-caserepresentation of a program instruction candidate responsive to theparsing of a partial program instruction statement, displaying aupper-case syntax representation of a program instruction verb candidateresponsive to the parsing of a partial program instruction statement,and displaying a leading upper-case syntax representation of a programinstruction verb candidate responsive to the parsing of a partialprogram instruction statement.
 7. A method for use in a computer systemfor providing a code assist function which suggests candidatesresponsive to a parsing of a partial program instruction statement, saidmethod comprising: determining a current cursor position in the partialprogram instruction statement; parsing the partial program instructionstatement before the current cursor position; generating a list ofcandidates to be inserted at the current cursor position responsive tothe parsing of the partial program instruction statement; applying auser-selected preference to the list of candidates to generate asuggested list of candidates; displaying the list of suggestedcandidates; allowing a user to select one of the list of suggestedcandidates; and inserting at the current cursor position theuser-selected suggested candidate.
 8. The method of claim 7 wherein theuser-selected preference comprises displaying a longer list of suggestedcandidates in lieu of a shorter list of suggested candidates.
 9. Themethod of claim 7 wherein the user-selected preference comprisesdisplaying a shorter list of suggested candidates in lieu of a longerlist of suggested candidates
 10. The method of claim 7 wherein theuser-selected preference comprises displaying a longer representation ofa program instruction verb suggested candidate in lieu of a shorterrepresentation of a program instruction verb suggested candidate. 11.The method of claim 7 wherein the user-selected preference comprisesdisplaying a full syntax representation of a suggested candidate in lieuof a partial syntax representation of a suggested candidate.
 12. Themethod of claim 7 wherein the user-selected preference comprises onefrom the set comprising displaying a lower-case representation of aprogram instruction candidate responsive to the parsing of a partialprogram instruction statement, displaying a upper-case syntaxrepresentation of a program instruction verb candidate responsive to theparsing of a partial program instruction statement, and displaying aleading upper-case syntax representation of a program instruction verbcandidate responsive to the parsing of a partial program instructionstatement.
 13. A computer system for providing a code assist functionwhich suggests candidates responsive to a parsing of a partial programinstruction statement, said computer system comprising: a current cursorposition in the partial program instruction statement; a parser forparsing the partial program instruction statement before the currentcursor position; a list of candidates to be inserted at the currentcursor position responsive to the parsing of the partial programinstruction statement; a user-selected preference applied to the list ofcandidates to generate a suggested list of candidates; a displayed listof suggested candidates; a selection by a user of one of the list ofsuggested candidates; and the user-selected suggested candidate insertedat the current cursor position.
 14. The computer system of claim 13wherein the user-selected preference comprises displaying a longer listof suggested candidates in lieu of a shorter list of suggestedcandidates.
 15. The computer system of claim 13 wherein theuser-selected preference comprises displaying a shorter list ofsuggested candidates in lieu of a longer list of suggested candidates.16. The computer system of claim 13 wherein the user-selected preferencecomprises displaying a longer representation of a program instructionverb suggested candidate in lieu of a shorter representation of aprogram instruction verb suggested candidate.
 17. The computer system ofclaim 13 wherein the user-selected preference comprises displaying afull syntax representation of a suggested candidate in lieu of a partialsyntax representation of a suggested candidate.
 18. The computer systemof claim 13 wherein the user-selected preference comprises one from theset comprising displaying a lower-case representation of a programinstruction candidate responsive to the parsing of a partial programinstruction statement, displaying a upper-case syntax representation ofa program instruction verb candidate responsive to the parsing of apartial program instruction statement, and displaying a leadingupper-case syntax representation of a program instruction verb candidateresponsive to the parsing of a partial program instruction statement.